package com.zc.manager.network.domain;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.zc.component.gateway.supports.DeviceGatewayProperties;

import java.util.Date;

/**
 * 设备网关实体类
 *
 * @author zhaoxianglong
 * @date 2022-11-7
 */
public class IotDeviceGateway {

    public static final String DISABLED = "disabled";
    public static final String ENABLED = "enabled";

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Excel(name = "网络组件ID")
    private Long networkId;

    @Excel(name = "网关类型")
    private String provider;

    @Excel(name = "网关名称")
    private String gatewayName;

    @Excel(name = "其他配置")
    private String configuration;

    @Excel(name = "启停状态")
    private String startState;

    @Excel(name = "描述")
    private String description;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Excel(name = "修改事件", dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
    private Date updateTime;

    public DeviceGatewayProperties toDeviceGatewayProperties() {

        DeviceGatewayProperties properties = new DeviceGatewayProperties();

        properties.setId(String.valueOf(this.id));
        properties.setProvider(this.provider);
        properties.setConfiguration(JSONObject.parseObject(configuration));
        properties.setNetworkId(String.valueOf(this.networkId));

        return properties;
    }

    public Long getNetworkId() {
        return networkId;
    }

    public void setNetworkId(Long networkId) {
        this.networkId = networkId;
    }

    public String getProvider() {
        return provider;
    }

    public void setProvider(String provider) {
        this.provider = provider;
    }

    public String getGatewayName() {
        return gatewayName;
    }

    public void setGatewayName(String gatewayName) {
        this.gatewayName = gatewayName;
    }

    public String getConfiguration() {
        return configuration;
    }

    public void setConfiguration(String configuration) {
        this.configuration = configuration;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getStartState() {
        return startState;
    }

    public void setStartState(String startState) {
        this.startState = startState;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
